package com.xzq.bugstack;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

import java.nio.charset.Charset;

/**
 * @Author xzq
 * @Description //TODO
 * @Date 2021/11/19 13:54
 * @Version 1.0.0
 **/
public class MyChannelIntializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline().addLast(new LineBasedFrameDecoder(1024));
        socketChannel.pipeline().addLast(new StringDecoder(Charset.forName("gbk")));
        socketChannel.pipeline().addLast(new StringEncoder(Charset.forName("gbk")));
        socketChannel.pipeline().addLast(new MyClientHandler());

    }
}
